//
//  BlankView.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/13.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "BlankView.h"


@interface BlankView()

@property (nonatomic, strong) UIButton *clickBtn;
@property (nonatomic, assign) NSInteger radius;
@property (nonatomic, strong) UIView *topLineView;
@end


@implementation BlankView

- (instancetype)initWithBackgroundColor:(UIColor*)backgroundColor
                              imageName:(NSString *)imageName
                           topLineTitle:(NSString *)topLineTitle
                        bottomLineTitle:(NSString *)bottomLineTitle
                           buttonRadius:(CGFloat)buttonRadius
                             buttonTint:(NSString *)buttonTint{
    if (self = [super init]) {
        [self loadSubviewsOnBlackViewWithBackgroundColor:backgroundColor imageName:imageName topLineTitle:topLineTitle bottomLineTitle:bottomLineTitle buttonRadius:buttonRadius buttonTint:buttonTint];
    }
    return self;
}

- (void)loadSubviewsOnBlackViewWithBackgroundColor:(UIColor*)backgroundColor
                                         imageName:(NSString *)imageName
                                      topLineTitle:(NSString *)topLineTitle
                                   bottomLineTitle:(NSString *)bottomLineTitle
                                      buttonRadius:(CGFloat)buttonRadius
                                        buttonTint:(NSString *)buttonTint{
    self.backgroundColor = backgroundColor;
    
    UIView *topLineView = [[UIView alloc]init];
    topLineView.backgroundColor = KLColor_B3;
    [self addSubview:topLineView];
    self.topLineView = topLineView;
    [topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(1);
    }];
    
    
    UIImageView *imageView = [[UIImageView alloc]init];
    imageView.image = [UIImage imageNamed:imageName];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(65*HEIGHT);
        make.centerX.equalTo(self);
        make.width.mas_equalTo(185*WIDTH);
        make.height.mas_equalTo(150*HEIGHT);
    }];
    
    UILabel *topTintLB = [[UILabel alloc]init];
    topTintLB.text = topLineTitle;
    topTintLB.textColor = KLColor_B8;
    topTintLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [self addSubview:topTintLB];
    [topTintLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(imageView.mas_bottom).offset(30*HEIGHT);
    }];
    
    UILabel *bottomTintLB = [[UILabel alloc]init];
    bottomTintLB.text = bottomLineTitle;
    bottomTintLB.textColor = KLColor_B8;
    bottomTintLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    [self addSubview:bottomTintLB];
    [bottomTintLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(topTintLB.mas_bottom).offset(15*HEIGHT);
    }];
    
    UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [clickBtn setTitle:buttonTint forState:UIControlStateNormal];
    [clickBtn setTitleColor:KLColor_A1 forState:UIControlStateNormal];
    clickBtn.titleLabel.font = [UIFont systemFontOfSize:16*WIDTH];
    [self addSubview:clickBtn];
    self.clickBtn = clickBtn;
    clickBtn.layer.borderWidth = 1;
    clickBtn.layer.borderColor = [KLColor_A1 CGColor];
    clickBtn.layer.cornerRadius = buttonRadius;
    clickBtn.layer.masksToBounds = YES;

    [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self).offset(-126*HEIGHT);
        make.width.mas_equalTo(160*WIDTH);
        make.height.mas_equalTo(36*HEIGHT);
    }];
    
    self.radius = buttonRadius;
}

- (void)setIsShowLine:(BOOL)isShowLine{
    
    self.topLineView.hidden = isShowLine;
}


@end
